<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>

        <ui:composition template="../templates/default3.xhtml">  

            <ui:define name="content">

                <h:form binding="#{salesOrderManagerBean.loadPurchaseOrdersPage}">
                    <p:panel header="Purchase Orders" id="purchaseOrdersPanel">
                        <p:messages />
                        <h:outputText value="Select the purchase order for quotation #{userSessionManagerBean.selectedQuotation.id}
                                      of #{userSessionManagerBean.selectedJob.customer.company}."/> <hr />
                        <p:dataTable id="purchaseOrders" var="purchaseOrder" value="#{salesOrderManagerBean.purchaseOrders}" paginator="true" 
                                     selectionMode="single" emptyMessage="No purchase order found with given criteria."
                                     selection="#{salesOrderManagerBean.selectedPurchaseOrder}"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="5,10,15" rows="10" 
                                     onRowSelectUpdate="btnCreateSalesOrder" onRowUnselectUpdate="btnCreateSalesOrder" 
                                     rowSelectListener="#{salesOrderManagerBean.onRowSelect}"
                                     rowUnselectListener="#{salesOrderManagerBean.onRowUnselect}">
                            <p:column headerText="PO Date"> 
                                <h:outputText value="#{purchaseOrder.poDate}">  
                                    <f:convertDateTime pattern="dd-MM-yyyy" timeZone="#{defaultManagerBean.tz}"/>
                                </h:outputText>
                            </p:column>
                            
                            <p:column filterBy="#{purchaseOrder.poNumber}" headerText="Subject" filterMatchMode="contains">  
                                <h:outputText value="#{purchaseOrder.poNumber}" />  
                            </p:column> 
                           
                          
                            <p:column filterBy="#{purchaseOrder.customer.company}" headerText="Company" filterMatchMode="contains">  
                                <h:outputText value="#{purchaseOrder.customer.company}" />  
                            </p:column> 
                             <p:column headerText="Remark" >  
                                <h:outputText value="#{purchaseOrder.remark}" />  
                            </p:column> 
                            
                              <p:column headerText="Total Amount" >  
                                <h:outputText value="#{purchaseOrder.totalAmount}" />  
                            </p:column> 
                            
                            
                            
                        </p:dataTable>
                        <p:commandButton id="btnBackToQuotation" value="Back" 
                                         actionListener="#{salesOrderManagerBean.back}" 
                                         ajax="true" update="purchaseOrdersPanel"/>
                        <p:commandButton id="btnNext" value="Next" 
                                         actionListener="#{salesOrderManagerBean.next}" 
                                         ajax="true" update="purchaseOrdersPanel"/>
                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
